<?php
session_start();
include('functions.php');
if(isset($_GET['logout'])) {
if($_GET['logout'] == 'true') {
$_SESSION = array();
?>
<script>
parent.location="http://<? echo $_SERVER["HTTP_HOST"]; echo dirname("$_SERVER[SCRIPT_NAME]"); ?>/";
</script>
<?php
}
}
/*****[BEGIN]******************************************
 [ Base:     oPanel Login check               v2.0.0 ]
 ******************************************************/
if ($_POST) {
$username = $_POST['username'];
  $error = login_check($_POST);
if($error=='new') {
    $_SESSION["user"] = $username;
    $_SESSION["pass"] = login($username, $_POST['password']);
    $_SESSION["power"] = power($_POST['username']);
    $_SESSION["home"] = HomeDir($_POST['username']);
    $_SESSION["trashdir"] = trash($username, 'dir');
    $_SESSION["trashfile"] = trash($username, 'file');
    $_SESSION["new"] = 'true';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> 
<title>oPanel Redirecting...</title>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<link rel="shortcut icon" href="favicon.ico" />
<style type='text/css' media="all">
@import url( "login.css" );
</style>
</head>
<body style='background-color:#D7D4FF;'>
<div id='wrapper'>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div align='center'>
<div style='width:500px;'>
<div class='outerdiv'>
<table cellpadding='0' cellspacing='8' width='100%' id='tablewrap'>
<tr>
 <td id='rightblock'>
<?php
if(isset($_POST['redirect']) && $_POST['redirect'] == 'admin') {
?>
<meta http-equiv="refresh" content="3; url='admin.php'" />
<?php
} else { echo '<meta http-equiv=\'refresh\' content=\'3; url=http://'.$_SERVER["HTTP_HOST"].dirname("$_SERVER[SCRIPT_NAME]").'/\' />'; }
?>
 <div>
  <table width='100%' cellpadding='0' cellspacing='0' border='0'>
  <tr>
   <td width='300' align="center" valign='top' bgcolor="#D7D4FF" style='width:300px; text-align: center;'><!--[if !IE]>--><p><!--<![endif]--><!--[if IE]><p< align='right'><![endif]--><img src='images/logo.png' alt='oPanel V3' border='0' /> <br />
     <img src="images/loading.gif" alt="Loading" width="100" height="100" /><br /><br />
         <strong>Log In Successful</strong></p>
     </td>
  </tr>
  </table>
 </div>
 </td>
</tr>

</table>
</div>
</div>
</div>
<br />
 <div class='copy' align='center'>oPanel V<? echo $ver; ?> &copy; <a href="http://olliespage.net" target="_blank">OlliesPage.net</a></div>
</div>
</body>
</html>
<?php
exit; } else if (trim($error)=="") {
    $_SESSION["user"] = $username;
    $_SESSION["pass"] = login($username, $_POST['password']);
    $_SESSION["power"] = power($_POST['username']);
    $_SESSION["home"] = HomeDir($_POST['username']);
    $_SESSION["trashdir"] = trash($username, 'dir');
    $_SESSION["trashfile"] = trash($username, 'file');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> 
<title>oPanel Redirecting...</title>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<link rel="shortcut icon" href="favicon.ico" />
<style type='text/css' media="all">
@import url( "login.css" );
</style>
</head>
<body style='background-color:#D7D4FF;'>
<div id='wrapper'>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div align='center'>
<div style='width:500px;'>
<div class='outerdiv'>
<table cellpadding='0' cellspacing='8' width='100%' id='tablewrap'>
<tr>
 <td id='rightblock'>
<?php
if(isset($_POST['redirect']) && $_POST['redirect'] == 'admin') {
?>
<meta http-equiv="refresh" content="3; url='admin.php'" />
<?php
} else { echo '<meta http-equiv=\'refresh\' content=\'3; url=http://'.$_SERVER["HTTP_HOST"].dirname("$_SERVER[SCRIPT_NAME]").'/\' />'; }
?>
 <div>
  <table width='100%' cellpadding='0' cellspacing='0' border='0'>
  <tr>
   <td width='300' align="center" valign='top' bgcolor="#D7D4FF" style='width:300px; text-align: center;'><!--[if !IE]>--><p><!--<![endif]--><!--[if IE]><p< align='right'><![endif]--><img src='images/logo.png' alt='oPanel V3' border='0' /> <br />
     <img src="images/loading.gif" alt="Loading" width="100" height="100" /><br /><br />
         <strong>Log In Successful</strong></p>
     </td>
  </tr>
  </table>
 </div>
 </td>
</tr>

</table>
</div>
</div>
</div>
<br />
 <div class='copy' align='center'>oPanel V<? echo $ver; ?> &copy; <a href="http://olliespage.net" target="_blank">OlliesPage.net</a></div>
</div>
</body>
</html>
<?php
    exit();
  } else {
/*****[BEGIN]******************************************
 [ Base:     oPanel Functions                  v1.5.0 ]
 ******************************************************/
        log_write('admin', "Invalid Password (".$_POST['password'].") was used in an attempted to access the oPanel for the user: ".$_POST['username']."", 'Hack Attempt');
/*****[END]********************************************
 [ Base:     oPanel Functions                  v1.5.0 ]
 ******************************************************/
?>
<html>
<head>
<title>oPanel V<? echo $ver; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet"href="style.css">
<link REL="shortcut icon" HREF="../images/logo.gif" TYPE="image/x-icon">
</head>
<body onLoad="document.forms[0].submit()">
<form target="_parent" action='<?php echo dirname($_SERVER["SCRIPT_NAME"]);
if(dirname($_SERVER["SCRIPT_NAME"]) != '/') echo '/'; 
if(isset($redirect)) echo '?redirect='.$redirect; ?>' method='post'>
<input type="hidden" value="<? echo $error; ?>" name="error">
</form>
<? exit;
?>
</body>
</html>
<?
  }
}
/*****[END]********************************************
 [ Base:     oPanel Login check               v2.0.0 ]
 ******************************************************/
?>